package design_pattern.prototype;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WeiDingKuo on 2017/10/26 16:35
 */
public class Test {
    public static void main(String[] args) {
        Prototype prototype = new Prototype();
        prototype.setA(1);
        List list1 = new ArrayList();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        prototype.setB(list1);

        Prototype prototype1 = prototype.clone();
        Prototype prototype2 = prototype.clone();

        System.out.println(prototype1.getA());
        System.out.println(prototype1.getB());
        System.out.println("==========");
        System.out.println(prototype2.getA());
        System.out.println(prototype2.getB());

        System.out.println("++++++++++");
        int a = prototype2.getA();
        a = 11;

        List list2 = prototype2.getB();
        list2.clear();
        list2.add(11);
        list2.add(22);
        list2.add(33);

        System.out.println(prototype1.getA());
        System.out.println(prototype1.getB());
        System.out.println("==========");
        System.out.println(prototype2.getA());
        System.out.println(prototype2.getB());
    }
}
